<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveRecord::ConnectionAdapters::Quoting</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveRecord::ConnectionAdapters::Quoting</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting_rb.html">
                vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001165">quote</a>&nbsp;&nbsp;
      <a href="#M001167">quote_column_name</a>&nbsp;&nbsp;
      <a href="#M001166">quote_string</a>&nbsp;&nbsp;
      <a href="#M001168">quote_table_name</a>&nbsp;&nbsp;
      <a href="#M001171">quoted_date</a>&nbsp;&nbsp;
      <a href="#M001170">quoted_false</a>&nbsp;&nbsp;
      <a href="#M001172">quoted_string_prefix</a>&nbsp;&nbsp;
      <a href="#M001169">quoted_true</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001165" class="method-detail">
        <a name="M001165"></a>

        <div class="method-heading">
          <a href="#M001165" class="method-signature">
          <span class="method-name">quote</span><span class="method-args">(value, column = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Quotes the column value to help prevent <a
href="http://en.wikipedia.org/wiki/SQL_injection">SQL injection
attacks</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001165-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001165-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 6</span>
 6:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quote</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">column</span> = <span class="ruby-keyword kw">nil</span>)
 7:         <span class="ruby-comment cmt"># records are quoted as their primary key</span>
 8:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">quoted_id</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:quoted_id</span>)
 9: 
10:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">value</span>
11:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>, <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Multibyte</span><span class="ruby-operator">::</span><span class="ruby-constant">Chars</span>
12:             <span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
13:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:binary</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:string_to_binary</span>)
14:               <span class="ruby-node">&quot;#{quoted_string_prefix}'#{quote_string(column.class.string_to_binary(value))}'&quot;</span> <span class="ruby-comment cmt"># ' (for ruby-mode)</span>
15:             <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&amp;&amp;</span> [<span class="ruby-identifier">:integer</span>, <span class="ruby-identifier">:float</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span>)
16:               <span class="ruby-identifier">value</span> = <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:integer</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_f</span>
17:               <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
18:             <span class="ruby-keyword kw">else</span>
19:               <span class="ruby-node">&quot;#{quoted_string_prefix}'#{quote_string(value)}'&quot;</span> <span class="ruby-comment cmt"># ' (for ruby-mode)</span>
20:             <span class="ruby-keyword kw">end</span>
21:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">NilClass</span>                 <span class="ruby-keyword kw">then</span> <span class="ruby-value str">&quot;NULL&quot;</span>
22:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">TrueClass</span>                <span class="ruby-keyword kw">then</span> (<span class="ruby-identifier">column</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:integer</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'1'</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">quoted_true</span>)
23:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">FalseClass</span>               <span class="ruby-keyword kw">then</span> (<span class="ruby-identifier">column</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:integer</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'0'</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">quoted_false</span>)
24:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Float</span>, <span class="ruby-constant">Fixnum</span>, <span class="ruby-constant">Bignum</span>    <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
25:           <span class="ruby-comment cmt"># BigDecimals need to be output in a non-normalized form and quoted.</span>
26:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">BigDecimal</span>               <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-value str">'F'</span>)
27:           <span class="ruby-keyword kw">else</span>
28:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:date</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:time</span>)
29:               <span class="ruby-node">&quot;'#{quoted_date(value)}'&quot;</span>
30:             <span class="ruby-keyword kw">else</span>
31:               <span class="ruby-node">&quot;#{quoted_string_prefix}'#{quote_string(value.to_yaml)}'&quot;</span>
32:             <span class="ruby-keyword kw">end</span>
33:         <span class="ruby-keyword kw">end</span>
34:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001167" class="method-detail">
        <a name="M001167"></a>

        <div class="method-heading">
          <a href="#M001167" class="method-signature">
          <span class="method-name">quote_column_name</span><span class="method-args">(column_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Quotes the column name. Defaults to no quoting.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001167-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001167-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 43</span>
43:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quote_column_name</span>(<span class="ruby-identifier">column_name</span>)
44:         <span class="ruby-identifier">column_name</span>
45:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001166" class="method-detail">
        <a name="M001166"></a>

        <div class="method-heading">
          <a href="#M001166" class="method-signature">
          <span class="method-name">quote_string</span><span class="method-args">(s)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Quotes a string, escaping any &#8217; (single <a
href="Quoting.html#M001165">quote</a>) and \ (backslash) characters.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001166-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001166-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 38</span>
38:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quote_string</span>(<span class="ruby-identifier">s</span>)
39:         <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\\/</span>, <span class="ruby-value str">'\&amp;\&amp;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/'/</span>, <span class="ruby-value str">&quot;''&quot;</span>) <span class="ruby-comment cmt"># ' (for ruby-mode)</span>
40:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001168" class="method-detail">
        <a name="M001168"></a>

        <div class="method-heading">
          <a href="#M001168" class="method-signature">
          <span class="method-name">quote_table_name</span><span class="method-args">(table_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Quotes the table name. Defaults to column name quoting.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001168-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001168-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 48</span>
48:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quote_table_name</span>(<span class="ruby-identifier">table_name</span>)
49:         <span class="ruby-identifier">quote_column_name</span>(<span class="ruby-identifier">table_name</span>)
50:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001171" class="method-detail">
        <a name="M001171"></a>

        <div class="method-heading">
          <a href="#M001171" class="method-signature">
          <span class="method-name">quoted_date</span><span class="method-args">(value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001171-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001171-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 60</span>
60:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quoted_date</span>(<span class="ruby-identifier">value</span>)
61:         <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">:db</span>)
62:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001170" class="method-detail">
        <a name="M001170"></a>

        <div class="method-heading">
          <a href="#M001170" class="method-signature">
          <span class="method-name">quoted_false</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001170-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001170-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 56</span>
56:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quoted_false</span>
57:         <span class="ruby-value str">&quot;'f'&quot;</span>
58:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001172" class="method-detail">
        <a name="M001172"></a>

        <div class="method-heading">
          <a href="#M001172" class="method-signature">
          <span class="method-name">quoted_string_prefix</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001172-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001172-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 64</span>
64:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quoted_string_prefix</span>
65:         <span class="ruby-value str">''</span>
66:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001169" class="method-detail">
        <a name="M001169"></a>

        <div class="method-heading">
          <a href="#M001169" class="method-signature">
          <span class="method-name">quoted_true</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001169-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001169-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 52</span>
52:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quoted_true</span>
53:         <span class="ruby-value str">&quot;'t'&quot;</span>
54:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>